/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.ACB;
import com.openbrew.openbrewrf.ATBeer;
import com.openbrew.openbrewrf.FinishedGoodsInventory;
import com.openbrew.openbrewrf.PSOLines;
import com.openbrew.openbrewrf.PackageType;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "FinishedGoodsInventory")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FGIView.findAll", query = "SELECT f FROM FGIView f ORDER BY f.fGIDescription ASC"),
    @NamedQuery(name = "FGIView.findAllInProduction", query = "SELECT f FROM FGIView f WHERE f.bBeerID.inProduction = 'true' ORDER BY f.fGIDescription ASC"),
    @NamedQuery(name = "FGIView.findAllNonProduction", query = "SELECT f FROM FGIView f WHERE f.bBeerID.inProduction = 'false' ORDER BY f.fGIDescription ASC"),
    @NamedQuery(name = "FGIView.findAllInStock", query = "SELECT f FROM FGIView f WHERE f.fGIQtyOnHand > '0' ORDER BY f.fGIDescription ASC")})
public class FGIView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "FGIID")
    private Integer fgiid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "FGIDescription")
    private String fGIDescription;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FGIQtyOnHand")
    private long fGIQtyOnHand;
    @JoinColumn(name = "FGIPackageID", referencedColumnName = "PackageTypeID")
    @ManyToOne(optional = false)
    private PackageType fGIPackageID;
    @JoinColumn(name = "FGIBeerID", referencedColumnName = "BId")
    @ManyToOne(optional = false)
    private BeerView bBeerID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "version")
    @Version
    private long version;
    @Basic(optional = false)
    @NotNull
    @Column(name = "servingTankVolume")
    private float servingTankVolume;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FGIQtyAllocated")
    private int fGIQtyAllocated;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FGIPriceCode")
    private float fGIPriceCode;
    @OneToMany(mappedBy = "psofgi")
    private Collection<PSOLines> psoLinesCollection;
    @OneToMany(mappedBy = "acbfgi")
    private Collection<ACB> acbCollection;
    @OneToMany(mappedBy = "atFgiID")
    private Collection<ATBeer> atCollection;

    public FGIView() {
    }

    public FGIView(Integer fgiid) {
        this.fgiid = fgiid;
    }

    public FGIView(Integer fgiid, String fGIDescription, long fGIQtyOnHand) {
        this.fgiid = fgiid;
        this.fGIDescription = fGIDescription;
        this.fGIQtyOnHand = fGIQtyOnHand;
    }

    public Integer getFgiid() {
        return fgiid;
    }

    public void setFgiid(Integer fgiid) {
        this.fgiid = fgiid;
    }

    public String getFGIDescription() {
        return fGIDescription;
    }

    public void setFGIDescription(String fGIDescription) {
        this.fGIDescription = fGIDescription;
    }

    public long getFGIQtyOnHand() {
        return fGIQtyOnHand;
    }

    public void setFGIQtyOnHand(long fGIQtyOnHand) {
        this.fGIQtyOnHand = fGIQtyOnHand;
    }

    public BeerView getFGIBeerID() {
        return bBeerID;
    }

    public void setFGIBeerID(BeerView bBeerID) {
        this.bBeerID = bBeerID;
    }

    public PackageType getFGIPackageID() {
        return fGIPackageID;
    }

    public void setFGIPackageID(PackageType fGIPackageID) {
        this.fGIPackageID = fGIPackageID;
    }

    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    public float getServingTankVolume() {
        return servingTankVolume;
    }

    public void setServingTankVolume(float servingTankVolume) {
        this.servingTankVolume = servingTankVolume;
    }

    public int getfGIQtyAllocated() {
        return fGIQtyAllocated;
    }

    public void setfGIQtyAllocated(int fGIQtyAllocated) {
        this.fGIQtyAllocated = fGIQtyAllocated;
    }

    public float getFGIPriceCode() {
        return fGIPriceCode;
    }

    public void setFGIPriceCode(float fGIPriceCode) {
        this.fGIPriceCode = fGIPriceCode;
    }

    @XmlTransient
    public Collection<PSOLines> getPSOLinesCollection() {
        return psoLinesCollection;
    }

    public void setPSOLinesCollection(Collection<PSOLines> psoLinesCollection) {
        this.psoLinesCollection = psoLinesCollection;
    }

    @XmlTransient
    public Collection<ACB> getACBCollection() {
        return acbCollection;
    }

    public void setACBCollection(Collection<ACB> acbCollection) {
        this.acbCollection = acbCollection;
    }

    @XmlTransient
    public Collection<ATBeer> getAtCollection() {
        return atCollection;
    }

    public void setAtCollection(Collection<ATBeer> atCollection) {
        this.atCollection = atCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (fgiid != null ? fgiid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FinishedGoodsInventory)) {
            return false;
        }
        FGIView other = (FGIView) object;
        if ((this.fgiid == null && other.fgiid != null) || (this.fgiid != null && !this.fgiid.equals(other.fgiid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.FinishedGoodsInventory[ fgiid=" + fgiid + " ]";
    }
}
